﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ex03.GarageLogic
{
    public enum eFuelType
    {
        Soler,
        Octan95,
        Octan96,
        Octan98
    }

    /// <summary>
    /// fuel vehicle own this class as its energy source
    /// </summary>
    internal class FuelPowered : EnergySource
    {        
        private readonly eFuelType m_FuelType;

        public FuelPowered(float i_MaxFuelLiters, eFuelType i_FuelType)
            : base(i_MaxFuelLiters)
        {
            m_FuelType = i_FuelType;
        }

        /// <summary>
        /// charge the energy source by using EnergySource.FillEnergy
        /// throw ArgumentException if the fuel type dosen't match
        /// </summary>
        /// <param name="i_FuelType"></param>
        /// <param name="i_HowMuchToFuel"></param>
        public void FuelTheTank(eFuelType i_FuelType, float i_HowMuchToFuel)
        {            
            if (i_FuelType == m_FuelType)
            {
                FillEnergy(i_HowMuchToFuel);
            }
            else
            {
                throw new ArgumentException("The Fuel Type Dosen't Match");
            }
        }

        /// <summary>
        /// Overriding <see cref="Object.ToString"/>
        /// </summary>
        /// <returns>string with Max fuel tank, Fuel left in tank and Fuel type</returns>
        public override string ToString()
        {
            string toString = string.Empty;

            toString = string.Format(@"
Max fuel tank: {0}
Fuel left in tank: {1}
Fuel type: {2}"
                , r_MaxEnergy
                , m_CurrentEnergy
                , m_FuelType);

            return toString;
        }
    }
}
